//
//  VideoModel.m
//  Delicious2
//
//  Created by FSD on 16/1/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "VideoModel.h"

@implementation VideoModel

- (instancetype)initWithDictionary:(NSDictionary *)data
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:data];
    }
    return self;
}

#pragma mark - 纠错方法
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"top"]) {
        NSArray *array = value;
        NSMutableArray *mutaleArray = [NSMutableArray arrayWithCapacity:0];
        for (NSDictionary *dic in array) {
            TopModel *topModel = [[TopModel alloc] initWithDictionary:dic];
            [mutaleArray addObject:topModel];
        }
        self.topDataSource = [NSArray arrayWithArray:mutaleArray];
    }
    
    if ([key isEqualToString:@"data"]) {
        NSArray *array = value;
        NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:0];
        for (NSDictionary *dic in array) {
            DataModel *dataModel = [[DataModel alloc] initWithDictionary:dic];
            [mutableArray addObject:dataModel];
        }
        self.dataDataSource = [NSArray arrayWithArray:mutableArray];
    }
}

@end
